<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>网络科学中国</title>
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<?php
require("config.inc.php");
include("function.php");
?>
<table width="810" height="23" border="0" align="center" cellpadding="0" cellspacing="0">
	<tr>
    	<td width="292" >
    		<div align="center"><font color=#FFFFFF style='font-size:9pt;font-family: 宋体'>今天是：</font>&nbsp;
    			<script language=JavaScript>
					   today=new Date();
					   function initArray(){
					   this.length=initArray.arguments.length
					   for(var i=0;i<this.length;i++)
					   this[i+1]=initArray.arguments[i]  }
					   var d=new initArray(
					     "星期日",
					     "星期一",
					     "星期二",
					     "星期三",
					     "星期四",
					     "星期五",
					     "星期六");
					   document.write(
					     "<font color=#FFFFFF style='font-size:9pt;font-family: 宋体'> ",
					     today.getFullYear(),"年",
					     today.getMonth()+1,"月",
					     today.getDate(),"日",
						  "&nbsp;&nbsp;",
					     d[today.getDay()+1],
						"</font>" ); 
    			</script>
    		</div>
    	</td>
    	<td>
    		<div align="center"><a href="mymessage.php">我要留言</a></div>
		</td>
    	<td>
    		<div align="center"><a href="index.php">网站首页</a></div>
    	</td>
	</tr>
 
 	<table width="810" height="500" border="0" align="center" cellpadding="0" cellspacing="0">
    	<tr>
    		<td  valign="top">	
	      		<?php
	     				 $sql="select count(*) as total from forum_message";
						 $result=mysql_query($sql);
						 $info=mysql_fetch_array($result);
						 $total=$info[total];
						 if($total==0)
						 {
						  echo "<div align=center>对不起，暂无留言！</div>";
						 }else
						 {
							   if(!isset($_GET["page"]) || !is_numeric($_GET["page"]))
							   {
							      $page=1; 
							   }else{
							      $page=intval($_GET["page"]);
							   }
							   
							   $pagesize=10;
							   if($total%$pagesize==0){
							      $pagecount=intval($total/$pagesize);
							   }else{
							      $pagecount=ceil($total/$pagesize);
							   }
							   $sql=mysql_query("select * from forum_message order by createtime desc limit ".($page-1)*$pagesize.",$pagesize  ");
							   while($info=mysql_fetch_array($sql))
							   {
	            ?>
				<table width="810" height="5" border="0" align="center" cellpadding="0" cellspacing="0"></table>
      			<table width="810" height="10" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#FCD424">
        			<tr>
          				<td bgcolor="#FFFFFF" valign="top">
          					<table width="810" height="24" border="0" align="center" cellpadding="0" cellspacing="0">
            					<tr>
              						<td width="450">用户名：<?php echo unhtml($info["user"]);?></td>
            					</tr>
          					</table>
            				<table width="810" height="5" border="0" align="center" cellpadding="0" cellspacing="0"></table>
							<table width="810" height="80" border="0" align="center" cellpadding="0" cellspacing="0">
              					<tr>
                					<td width="390" rowspan="2">留言：<?php echo unhtml($info["content"]);?></td>
              					</tr>
            				</table>
            				<table width="810" height="5" border="0" align="center" cellpadding="0" cellspacing="0">
            				    <tr>
                					<td width="390" rowspan="2">时间：<?php echo unhtml($info["createtime"]);?></td>
              					</tr>
            				</table>
		  				</td>
        			</tr>
      			</table>
						   <?php
								 }
						}
							?>
	   			<table width="810" height="25" border="0" align="center" cellpadding="0" cellspacing="0">
         			<tr>
           				<td width="351"><div align="left">共有留言&nbsp;<?php echo $total;?>&nbsp;条&nbsp;每页显示&nbsp;<?php echo $pagesize;?>&nbsp;条&nbsp;第&nbsp;<?php echo $page;?>&nbsp;页/共&nbsp;<?php echo $pagecount;?>&nbsp;页</div></td>
           				<td width="199">
           					<div align="right">
           						<a href="<?php echo $_SERVER["PHP_SELF"]?>?page=1" class="a1">首页</a>&nbsp;
           						<a href="<?php echo $_SERVER["PHP_SELF"]?>?page=
           							<?php 
					 					if($page>1) 
					   						echo $page-1;
					  					else
					   						echo 1;  
		   							?>
		   								" class="a1">上一页</a>
		   						&nbsp;
		   						<a href="<?php echo $_SERVER["PHP_SELF"]?>?page=
		   							<?php 
						 				if($page<$pagecount) 
						   					echo $page+1;
						  				else
						   					echo $pagecount;  
		   							?>
		   								" class="a1">下一页&nbsp;</a>
		   						<a href="<?php echo $_SERVER["PHP_SELF"]?>?page=
		   							<?php echo $pagecount;?>
		   								"class="a1">尾页</a>
		   					</div>
		   				</td>   					   				
					</tr>
       			</table>
       		</td>
  		</tr>
	</table>
</table>
<?php
	include("footer.php");
?>
</body>
</html>
